/*
 * FileName: localtime.cc
 * Author: 李波(Edwin Lee)
 * Date: 2024-08-01 13:36:52
 * Version: 1.0
 * Description: localtime练习
 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// localtime的安全版本，window下使用localtime_s,linux下使用localtime_r
#ifdef WIN32
#define LOCALTIME(time,result) localtime_s(result,time)
#else
#define LOCALTIME(time,result) localtime_r(time,result)
#endif
int main()
{
	time_t now = time(NULL);
	tm info;
	LOCALTIME(&now,&info);
	int year = info.tm_year+1900;
	int month = info.tm_mon+1;
	int month_day = info.tm_mday;
	int week = info.tm_wday;
	int hour = info.tm_hour;
	int second = info.tm_sec;
	int minute = info.tm_min;
	printf("%d-%d-%d %d:%d:%d", year, month, month_day, hour, minute, second);

}
